package com.atguigu.controller;

import com.atguigu.commonutils.R;
import com.atguigu.service.OssService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/eduOss/fileOss")
//@CrossOrigin
public class OssController {
    @Resource
    private OssService ossService;

    @PostMapping
    public R uploadOssFile(MultipartFile file){
        //获取上传文件MultipartFile
        //返回上传到OSS的路径
        String url = ossService.uploadAvatar(file);
        return R.ok().data("url",url);

    }
}
